package com.jt.pojo;

import lombok.Data;
import lombok.experimental.Accessors;

/**
 * 统一返回对象
 */
@Data
@Accessors(chain = true)
public class Result<T> {
    private int code;
    private Object data;
    private String massage;

    public static <T> Result<T> success(T object) {
        Result<T> r = new Result<>();
        r.code = 1;
        r.data = object;
        return r;
    }

    public static <T> Result<T> error(String masege) {
        Result<T> r = new Result<>();
        r.code = 0;
        r.massage = masege;
        return r;
    }

    public Result(int code, Object data, String masege) {
        this.code = code;
        this.data = data;
        this.massage = masege;
    }

    public Result() {
    }
}
